package com.derbysoft.synxisadapter.action.monitor.transactionlog;

import com.derbysoft.core.LimitedList;
import com.derbysoft.synxisadapter.action.BaseAdapterAction;
import com.derbysoft.synxisadapter.commons.model.TransactionLog;
import com.derbysoft.synxisadapter.commons.repository.TransactionLogRepository;
import com.derbysoft.synxisadapter.commons.repository.impl.TransactionLogCondition;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;


@Results(value = {
        @Result(name = Action.SUCCESS, location = "/page/monitor/transactionlog/Query.ftl")
})
public class QueryAction extends BaseAdapterAction {

    @Autowired
    private TransactionLogRepository transactionLogRepository;

    private TransactionLogCondition condition = new TransactionLogCondition();
    private LimitedList<TransactionLog> transactionLogs = new LimitedList<TransactionLog>();

    public String query() throws Exception {
        transactionLogs = transactionLogRepository.findByCondition(condition, createLimit());
        paging(transactionLogs);
        return SUCCESS;
    }

    public TransactionLogCondition getCondition() {
        return condition;
    }

    public void setCondition(TransactionLogCondition condition) {
        this.condition = condition;
    }

    public LimitedList<TransactionLog> getTransactionLogs() {
        return transactionLogs;
    }
}
